// BinarySearch.cpp : This file contains the 'main' function. Program execution begins and ends there.
//

#include <iostream>
#include"BinarySearch.h"

int main()
{
    List* list = InitList(7);
    ListAdd(list, 1);
    ListAdd(list, 2);
    ListAdd(list, 3);
    ListAdd(list, 4);
    ListAdd(list, 5);
    ListAdd(list, 6);
    ListAdd(list, 7);

    ListPrint(list);

    printf("二分查找 5, 位置在 :%d\n", BinartSearch(list, 5));
    printf("二分查找 6, 位置在 :%d\n", BinartSearch(list, 6));
    printf("二分查找 2, 位置在 :%d\n", BinartSearch(list, 2));
    printf("二分查找 3, 位置在 :%d\n", BinartSearch(list, 3));
    printf("二分查找 1, 位置在 :%d\n", BinartSearch(list, 1));
    printf("二分查找 10, 位置在 :%d\n", BinartSearch(list, 10));

    printf("============================================\n");

    printf("二分查找递归实现 5, 位置在 :%d\n", BinarySearchRecursion(list, 0, list->num, 5));
    printf("二分查找递归实现 6, 位置在 :%d\n", BinarySearchRecursion(list, 0, list->num, 6));
    printf("二分查找递归实现 2, 位置在 :%d\n", BinarySearchRecursion(list, 0, list->num, 2));
    printf("二分查找递归实现 3, 位置在 :%d\n", BinarySearchRecursion(list, 0, list->num, 3));
    printf("二分查找递归实现 1, 位置在 :%d\n", BinarySearchRecursion(list, 0, list->num, 1));
    printf("二分查找递归实现 10, 位置在 :%d\n", BinarySearchRecursion(list, 0, list->num, 10));
}
